import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
//不用权限的公用路由
export const constantRouterMap = [
  {
    path: '/',
    name: 'index',
    type: 'IndexNav',
    title: "首页",
    components: {
      default: () => import('@/pages/Home/home'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    },
    children: [

    ]

  },

  {
    path: "/electricCars",
    name: "electricCars",
    type: 'IndexNav',
    title: "电动车馆",
    components: {
      default: () => import('@/pages/electricCars/electricCars'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    }
  },
  {
    path: "/motorcycle",
    name: "motorcycle",
    type: 'IndexNav',
    title: "摩托车馆",
    components: {
      default: () => import('@/pages/electricCars/motorcycle'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    }
  },
  {
    path: "/Battery",
    name: "Battery",
    type: 'IndexNav',
    title: "新能源电池",
    components: {
      default: () => import('@/pages/batteryDoor/batteryDoor'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')

    }
  },
  {
    path: '/electricVehicleSupplies',
    name: "ElectricVehicleSupplies",
    type: 'IndexNav',
    title: "配件中心",
    components: {
      default: () => import('@/pages/ElectricVehicleSupplies/ElectricVehicleSupplies'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')

    }
  },
  {
    path: '/accessoriesShop',
    name: "AccessoriesShop",
    type: 'IndexNav',
    title: "服务网点",
    components: {
      default: () => import('@/pages/AccessoriesShop/AccessoriesShop'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')

    }
  },
  {
    path: '/join',
    name: "join",
    type: 'IndexNav',
    title: "招商合作",
    components: {
      default: () => import('@/pages/join/join'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')

    }
  },
  {
    path: "/Mtire",
    name: "Mtire",
    components: {
      default: () => import('@/pages/Tire/tire'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')

    }

  },
  {
    path: "/login",
    name: "login",
    components: {
      default: () => import('@/components/login/login'),
    }

  },
  {
    path: "/products/:proid/",
    name: "products",
    components: {
      default: () => import('@/pages/Products/products'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    }
  },
  {
    path: "/listgoods/:c1/:c2/:c3",
    name: "listgoods",
    components: {
      default: () => import('@/pages/ListGoods/ListGoods'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    }
  },
  {
    path: "/order",
    name: "order",
    components: {
      default: () => import('@/pages/order/order'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    }
  },

]
//需要权限的路由
export const asyncRouterMap = [
  {
    path: "/user",
    name: "user",
    label: "用户",
    meta: { role: ['user', 'super_editor'] },
    components: {
      default: () => import('@/pages/user/user'),
      Header: () => import('@/pages/Header/header'),
      Side: () => import('@/pages/Side/side'),
      Footer: () => import('@/pages/Footer/footer')
    },
    children: [
      {
        path: '',
        label: "用户中心",
        name: "userCenter",
        component: () => import('@/pages/user/broadside/userCenter'),
      },
      {
        path: 'myOrder',
        name: 'myOrder',
        label: "我的订单",
        component: () => import('@/pages/user/broadside/myOrder'),
        // children: [
        //   {
        //     path: 'wid',
        //     label: '未付款',
        //     component: () => import(  '@/pages/user/broadside/myOrder'),
        //   }
        // ]
      },
      {
        path: 'myFavorite',
        name: 'myFavorite',
        label: "我的收藏",
        component: () => import('@/pages/user/broadside/myFavorite'),
      },
      {
        path: 'myFootprint',
        name: 'myFootprint',
        label: "我的足迹",
        component: () => import('@/pages/user/broadside/myFootprint'),
      },
      {
        path: 'personalInformation',
        name: 'personalInformation',
        label: "个人信息",
        component: () => import('@/pages/user/broadside/personalInformation'),
      },
      {
        path: 'myOffer',
        name: 'myOffer',
        label: "我的优惠信息",
        component: () => import('@/pages/user/broadside/myOffer'),
      },
    ]
  },
  {
    path: "/ShoppingCart",
    name: "ShoppingCart",
    label: "购物车",
    meta: { role: ['user', 'super_editor'] },
    components: {
      default: () => import('@/pages/ShoppingCart/ShoppingCart'),
      Side: () => import('@/pages/Side/side'),
    },
  },
  { path: '*', meta: { role: ['user', 'super_editor'] }, component: () => import('@/components/404/not') }
];
//实例化vue的时候只挂载constantRouter
export default new Router({
  // mode: 'history',
  routes: constantRouterMap
});
